Tracking changes to "/etc" with git for backup
From Gentoo Wiki
Tracking the /etc directory with git is a common procedure within the Gentoo community - although tools exist to solve configuration file change management (such as dispatch-conf or etckeeper).
Quick and dirty
The gist of dirty configuration file management with git is as follows:
- Change to the /etc directory:
root #cd /etc- Initialize a new git repository:
root #git init- Commit initial the initial state and any further known good revisions:
root #git add * # add all files not in git to the .gitignore fileroot #git commit -m 'required'
- To investigate revisions:
root #git rev-list #display all revisions
- To checkout/load a specific revision:
root #git checkout #<(insert a revision hash here>
- To revert unwanted changes:
root #git reset --hard # undo all changes from revision checked out
- Alternatively:
root #git resetroot #git checkout .
See also
- dispatch-conf — a utility included with Portage, used to safely and conveniently manage configuration files after package updates.
- etckeeper — a collection of tools to store /etc in a VCS (version control) repository, to keep a backup of changes to system configuration files